package com.company;


import com.company.service.Goods;

import java.util.*;

public class Task5 {
    public static void main(String[] args) {
        //todo 5.定义一个商品类（id, 名称，分类，售价，创建时间），重写toString，可以输出json形式的商品信息，同时实现Comparable接口，能在TreeSet中按创建时间倒序排列。
        Goods g1 = new Goods();
        g1.setId(1);
        g1.setName("随便");
        g1.setCategory(1);
        g1.setCreateTime("2020-10-23 1:00:00");
        System.out.println(g1.toString());

        Goods g2 = new Goods();
        g2.setId(2);
        g2.setName("泡面");
        g2.setCategory(1);
        g2.setCreateTime("2020-10-23 2:00:00");
        System.out.println(g2.toString());

        Goods g3 = new Goods();
        g3.setId(3);
        g3.setName("火腿肠");
        g3.setCategory(1);
        g3.setCreateTime("2020-10-23 3:00:00");
        System.out.println(g3.toString());

        TreeSet<Goods> treeSet = new TreeSet<>();
        treeSet.add(g1);
        treeSet.add(g2);
        treeSet.add(g3);

        System.out.println(treeSet);

    }


}
